package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.CustContactsSerialno;
import com.ruoyi.bizsys.service.ICustContactsSerialnoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通讯录流水号关联Controller
 *
 * @author african-loan
 * @date 2022-01-07
 */
@RestController
@RequestMapping("/bizsys/serialno")
public class CustContactsSerialnoController extends BaseController {
    @Autowired
    private ICustContactsSerialnoService custContactsSerialnoService;

/**
 * 查询通讯录流水号关联列表
 */
@PreAuthorize("@ss.hasPermi('bizsys:serialno:list')")
@GetMapping("/list")
        public TableDataInfo list(CustContactsSerialno custContactsSerialno) {
        startPage();
        List<CustContactsSerialno> list = custContactsSerialnoService.selectCustContactsSerialnoList(custContactsSerialno);
        return getDataTable(list);
    }
    
    /**
     * 导出通讯录流水号关联列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:serialno:export')")
    @Log(title = "通讯录流水号关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CustContactsSerialno custContactsSerialno) {
        List<CustContactsSerialno> list = custContactsSerialnoService.selectCustContactsSerialnoList(custContactsSerialno);
        ExcelUtil<CustContactsSerialno> util = new ExcelUtil<CustContactsSerialno>(CustContactsSerialno.class);
        return util.exportExcel(list, "serialno");
    }

    /**
     * 获取通讯录流水号关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:serialno:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(custContactsSerialnoService.selectCustContactsSerialnoById(id));
    }

    /**
     * 新增通讯录流水号关联
     */
    @PreAuthorize("@ss.hasPermi('bizsys:serialno:add')")
    @Log(title = "通讯录流水号关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustContactsSerialno custContactsSerialno) {
        return toAjax(custContactsSerialnoService.insertCustContactsSerialno(custContactsSerialno));
    }

    /**
     * 修改通讯录流水号关联
     */
    @PreAuthorize("@ss.hasPermi('bizsys:serialno:edit')")
    @Log(title = "通讯录流水号关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustContactsSerialno custContactsSerialno) {
        return toAjax(custContactsSerialnoService.updateCustContactsSerialno(custContactsSerialno));
    }

    /**
     * 删除通讯录流水号关联
     */
    @PreAuthorize("@ss.hasPermi('bizsys:serialno:remove')")
    @Log(title = "通讯录流水号关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(custContactsSerialnoService.deleteCustContactsSerialnoByIds(ids));
    }
}
